]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
osdWindow: Disconnect signals on destroy
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 23 Sep 2018 01:06:21 +0000 (03:06 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 22 Oct 2018 14:58:50 +0000 (14:58 +0000)
Since we started to show OSD windows on all monitors, OSD windows are
destroyed when the corresponding monitor is disconnected. We shouldn't
leave any signal handlers around in that case - they prevent the object
from being garbage collected, and trigger warnings for accessing proper-
ties of invalidated GObjects.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/602

js/ui/osdWindow.js

index fb6587be0136c65ab70db0db24735c86a83cfe65..d7077a063c3717df3fa9859055c93770e37fd7d0 100644 (file)
@@ -118,15 +118,30 @@ var OsdWindow = new Lang.Class({
         this._hideTimeoutId = 0;
         this._reset();
 
-        Main.layoutManager.connect('monitors-changed',
-                                   this._relayout.bind(this));
+        this.actor.connect('destroy', this._onDestroy.bind(this));
+
+        this._monitorsChangedId =
+            Main.layoutManager.connect('monitors-changed',
+                                       this._relayout.bind(this));
         let themeContext = St.ThemeContext.get_for_stage(global.stage);
-        themeContext.connect('notify::scale-factor',
-                             this._relayout.bind(this));
+        this._scaleChangedId =
+            themeContext.connect('notify::scale-factor',
+                                 this._relayout.bind(this));
         this._relayout();
         Main.uiGroup.add_child(this.actor);
     },
 
+    _onDestroy() {
+        if (this._monitorsChangedId)
+            Main.layoutManager.disconnect(this._monitorsChangedId);
+        this._monitorsChangedId = 0;
+
+        let themeContext = St.ThemeContext.get_for_stage(global.stage);
+        if (this._scaleChangedId)
+            themeContext.disconnect(this._scaleChangedId);
+        this._scaleChangedId = 0;
+    },
+
     setIcon(icon) {
         this._icon.gicon = icon;
     },